gh-145792: Fix incorrect alloca allocation size in traceback.c#145814
Open
VanshAgarwal24036 wants to merge 3 commits intopython:mainfrom
Open
gh-145792: Fix incorrect alloca allocation size in traceback.c#145814VanshAgarwal24036 wants to merge 3 commits intopython:mainfrom
VanshAgarwal24036 wants to merge 3 commits intopython:mainfrom
Conversation
Contributor
Author
|
@vstinner Please review it when you are free. |
kumaraditya303
approved these changes
Mar 12, 2026
vstinner
reviewed
Mar 12, 2026
| try: | ||
| recurse(50) | ||
| except RuntimeError as exc: | ||
| tb = traceback.format_exception(exc) |
Member
There was a problem hiding this comment.
The test is unrelated to the fix, I suggest removing it. I tried to write a test using faulthandler.dump_c_stack() but I don't know how to create a long C stack. The Python recurse() reuses the same _PyEval_EvalFrameDefault frame for the 50 calls.
Comment on lines
+1
to
+2
| Fix incorrect memory allocation in the VLA fallback macro in traceback.c | ||
| when using alloca(), preventing potential out-of-bounds access. |
Member
There was a problem hiding this comment.
Suggested change
| Fix incorrect memory allocation in the VLA fallback macro in traceback.c | |
| when using alloca(), preventing potential out-of-bounds access. | |
| Fix incorrect memory allocation in the ``VLA()`` macro in ``traceback.c`` | |
| when using ``alloca()``, preventing potential stack overflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix incorrect memory allocation when using the VLA fallback macro in traceback.c with alloca(). The previous implementation allocated only size bytes instead of sizeof(type) * size, which could lead to out-of-bounds access.
A regression test and NEWS entry are included.
traceback.cwhenalloca()is used over VLA #145792